package syb.air.thp.plugin;

import com.zhny.aiot.plugin.ICenterFacilities;
import com.zhny.aiot.plugin.IDevice;
import com.zhny.aiot.plugin.modbus.ModemServer;
import com.zhny.aiot.plugin.modbus.device.ModemConfig;
import com.zhny.aiot.plugin.modbus.device.ModemDeviceFactory;
import com.zhny.aiot.plugin.modbus.handler.model.ModemRequestMessage;
import com.zhny.aiot.plugin.model.DeviceEntity;
import com.zhny.aiot.plugin.model.FactoryType;
import com.zhny.aiot.plugin.model.StoreEntity;
import org.pf4j.Extension;
import org.pf4j.Plugin;
import org.pf4j.PluginWrapper;
import syb.air.thp.plugin.model.TemperatureHumidityPressureStoreEntry;

public class TemperatureHumidityPressurePlugin extends Plugin {
    public TemperatureHumidityPressurePlugin(PluginWrapper wrapper) {
        super (wrapper);
    }

    @Extension
    public static class RadiationFactory extends ModemDeviceFactory<TemperatureHumidityPressureStoreEntry> {

        public ModemRequestMessage getRequestMessage(ModemConfig modemConfig) {
            return new ModemRequestMessage (Integer.parseInt (modemConfig.getAddress ()), (short) 3, 0, 3);
        }

        public IDevice createDevice(ICenterFacilities iCenterFacilities, DeviceEntity entity) {
            return new TemperatureHumidityPressureDevice (ModemServer.getInstance ().getEngine (), this, iCenterFacilities, entity);
        }

        public Class<? extends StoreEntity> storeClass() {
            return TemperatureHumidityPressureStoreEntry.class;
        }

        public String getId() {
            return "syb-temperature-humidity-pressure-plugin";
        }

        public String getName() {
            return "事业部温湿压设备插件";
        }

        public FactoryType getType() {
            return FactoryType.WeatherStation;
        }
    }
}